% Imports time-series data
% Code based on Gertler and Karadi (2015)
clear

TT = readtable('../00_Data/IP_data.xls'); % year; month; data;
data_IP = table2array(TT);
data_IP = data_IP(:,1:3);

TT = readtable('../00_Data/Misrep_data.xls');  % year; month; data
data_MRep = table2array(TT);
data_MRep = data_MRep(:,1:3);

TT = readtable('../00_Data/EMBI_data.xls');
data_EMBI = table2array(TT);
data_EMBI = data_EMBI(:,1:3);

data_in = [data_IP data_MRep(:,3) data_EMBI(:,3) ];


% VAR
DATASET_VAR.TSERIES = data_in(:,1:5);
DATASET_VAR.LABEL   = {'YEAR','MONTH','IP', 'MRep', 'SP'};
DATASET_VAR.VALUE   = [   1,     2,     3,    4,     5  ];

% Creates a mapping between labels and values
DATASET_VAR.MAP = containers.Map(DATASET_VAR.LABEL,DATASET_VAR.VALUE);


% Factors
TT = readtable('../00_Data/FACTOR_data.xls'); % year; month; median_dBE
data_in = table2array(TT);
DATASET_FACTORS.TSERIES = [data_in(:,1:2) data_in(:,3)];
DATASET_FACTORS.LABEL   = {'YEAR','MONTH','dBE'};
DATASET_FACTORS.VALUE   = [   1,     2   ,  3  ];

% Creates a mapping between labels and values
DATASET_FACTORS.MAP = containers.Map(DATASET_FACTORS.LABEL,DATASET_FACTORS.VALUE);

save('../00_Data/DATASET.mat','DATASET_VAR','DATASET_FACTORS');

